#include "safescanbottom.h"
#include <QHBoxLayout>
#include <QPropertyAnimation>
#include <QVBoxLayout>
#include "scanbuttonwidget.h"
#include "../../commom/statictextbutton.h"

SafeScanBottom::SafeScanBottom(QWidget *parent) :
    BaseStyleWidget(parent)
{
    this->initUI();
    this->initConnect();
    this->setStyleSheet("QWidget{background:white;}");
}

void SafeScanBottom::initUI()
{
//    m_quick = new ScanButtonWidget;
//    m_quick->setObjectName("quickButton");

//    m_full = new ScanButtonWidget;
//    m_full->setObjectName("fullButton");

//    m_custom = new ScanButtonWidget;
//    m_custom->setObjectName("customButton");

//    this->setFixedSize(900, 600);

    m_test1Button = new StaticTextButton;
    m_test1Button->setObjectName("test1Button");
    m_test2Button = new StaticTextButton;
    m_test2Button->setObjectName("test2Button");
    m_test3Button = new StaticTextButton;
    m_test3Button->setObjectName("test3Button");
    m_test4Button = new StaticTextButton;
    m_test4Button->setObjectName("test4Button");
    m_test5Button = new StaticTextButton;
    m_test5Button->setObjectName("test5Button");
    m_test6Button = new StaticTextButton;
    m_test6Button->setObjectName("test6Button");
    QGridLayout *scanLayout = new QGridLayout;
    scanLayout->addWidget(m_test1Button, 1, 0);
    scanLayout->addWidget(m_test2Button, 1, 1);
    scanLayout->addWidget(m_test3Button, 1, 2);
    scanLayout->addWidget(m_test4Button, 2, 0);
    scanLayout->addWidget(m_test5Button, 2, 1);
    scanLayout->addWidget(m_test6Button, 2, 2);
    scanLayout->setContentsMargins(0, 0, 0, 0);

//    QPropertyAnimation *m_upMainAnimation = new QPropertyAnimation(this, "pos");
//    m_upMainAnimation->setDuration(200);
//    m_upMainAnimation->setStartValue(QPoint(0, 110));
//    m_upMainAnimation->setEndValue(QPoint(0, -440));

    QPropertyAnimation *m_downMainAnimation = new QPropertyAnimation(this, "pos");
    m_downMainAnimation->setDuration(200);
    m_downMainAnimation->setStartValue(QPoint(0, 440));
    m_downMainAnimation->setEndValue(QPoint(0, 600));

    m_upGroup = new QParallelAnimationGroup;
//    m_upGroup->addAnimation(m_upMainAnimation);
    m_upGroup->addAnimation(m_downMainAnimation);


    m_testWidget = new QStackedWidget();//打开后的页面大小
    m_testWidget->setGeometry(rect());
    m_testWidget->lower();
//    m_safeWidget = new SafeWidget;
//    m_testWidget->addWidget(m_safeWidget);
    m_cleanWidget = new CleanWidget;
    m_testWidget->addWidget(m_cleanWidget);
    m_youhuaWidget = new YouhuaWidget;
    m_testWidget->addWidget(m_youhuaWidget);
    m_fix = new StaticTextButton;
    m_fix->setObjectName("fixButton");

    m_patch = new StaticTextButton;
    m_patch->setObjectName("patchButton");

    QHBoxLayout *staticLayout = new QHBoxLayout;
    staticLayout->addStretch();
    staticLayout->addWidget(m_fix);
    staticLayout->addWidget(m_patch);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addStretch();
    mainLayout->addLayout(scanLayout);
    mainLayout->addLayout(staticLayout);

    mainLayout->addSpacing(20);

    this->setLayout(mainLayout);

}

void SafeScanBottom::initConnect()
{
//    connect(m_quick, SIGNAL(buttonClicked()), this, SIGNAL(quickClicked()));
//    connect(m_full, SIGNAL(buttonClicked()), this, SIGNAL(fullClicked()));
//    connect(m_custom, SIGNAL(buttonClicked()), this, SIGNAL(customClicked()));
//    connect(m_fix, SIGNAL(buttonClicked()), this, SIGNAL(fixClicked()));
    connect(m_test1Button, SIGNAL(buttonClicked()), this, SIGNAL(axisClicked()));
    connect(m_test2Button, SIGNAL(buttonClicked()), this, SIGNAL(cleanClicked()));
    connect(m_test3Button, SIGNAL(buttonClicked()), this, SIGNAL(youhuaClicked()));

//    connect(m_upGroup, SIGNAL(finished()), this, SLOT(upAnimFinished()));

}
//void SafeScanBottom::goToSafe()
//{
//    m_testWidget->setCurrentIndex(0);//表示打开哪一个
////    m_upGroup->start();
//}

//void SafeScanBottom::goToClean()
//{
//    m_testWidget->setCurrentIndex(1);
//    m_upGroup->start();
//    m_cleanWidget->startFirst();//页面打开动画
//}

//void SafeScanBottom::goToYouhua()
//{
//    m_testWidget->setCurrentIndex(2);
//    m_upGroup->start();
//}
